home *** CD-ROM | disk | FTP | other *** search
- {$APPTYPE CONSOLE}
- uses
- DrBobCGI, DrBobSys, IndexBob;
- var
- Keywords,Keyword: ShortString;
- Found,SubSet: TPageSet;
- i: Integer;
-
- function GetNextKeyword: ShortString;
- begin
- if Pos(' ',Keywords) > 0 then
- begin
- Result := Copy(Keywords,1,Pos(' ',Keywords)-1);
- Delete(Keywords,1,Pos(' ',Keywords))
- end
- else
- begin
- Result := Keywords;
- Keywords := ''
- end
- end {GetNextKeyword};
-
- var
- f: Text;
- Query: Integer;
- _Or, _Not: Boolean;
- begin
- writeln('<H2>IndexBob Search Results</H2>');
- Keywords := Value('Keyword');
- if ValueAsInteger('Book') > 0 then Keywords := 'Book Review and '+Keywords;
- if ValueAsInteger('Tool') > 0 then Keywords := 'Tool Review and '+Keywords;
- { COUNTER }
- Assign(f,'indexbob');
- Reset(f);
- if IOResult = 0 then readln(f,Query)
- else Query := 0;
- Inc(Query);
- rewrite(f);
- writeln(f,Query);
- close(f);
- if IOResult <> 0 then { skip };
- Assign(f,'indexbob.log');
- Append(f);
- if IOResult <> 0 then Rewrite(f);
- writeln(f,Query:7,': ',Keywords);
- Close(f);
- if IOResult <> 0 then { skip };
- writeln('Search: <B>',Query,'</B> since 1997/11/25<BR>');
- writeln('Keyword: <B>',Keywords,'</B><BR>');
- Keywords := LowerCase(Keywords);
- Found := [0..WebPages-1];
- Query := 0; { no queries performed, yet }
- _Not := False;
- _Or := False;
- if root <> nil then
- repeat
- Keyword := GetNextKeyword;
- if Keyword = 'and' then { skip }
- else
- begin
- if Keyword = 'or' then _Or := True
- else
- begin
- if Keyword = 'not' then _Not := True
- else
- begin
- if Length(Keyword) > 2 then
- begin
- SubSet := root.FindKeywordInPages(Keyword);
- if SubSet = [] then
- writeln('<BR>Invalid keyword: <I>',Keyword,'</I>')
- else
- begin
- if _Not then SubSet := [0..WebPages-1] - SubSet;
- _Not := False;
- if _Or then
- Found := Found + SubSet
- else { and }
- Found := Found * SubSet;
- Inc(Query)
- end
- end
- end
- end
- end
- until Keywords = '';
- if Query = 0 then Found := []; { no SubSet found }
- writeln('<BR>');
- write('<B>',Pages(Found),'</B> pages found');
- Query := 0;
- Keywords := LowerCase(Value('Keyword'));
- Keyword := GetNextKeyword; { first keyword }
- for i:=0 to WebPages-1 do
- begin
- if (i in Found) then
- begin
- if Titles[i] = '' then
- Found := Found - [i] // skip empty title!!
- else
- if Pos(Keyword,LowerCase(Titles[i])) > 0 then Inc(Query)
- end
- end;
- if Query > 0 then write('<B> (',Query,' hot)</B>');
- writeln(':');
- writeln('<UL>');
- if Query > 0 then
- begin
- for i:=0 to WebPages-1 do
- begin
- if (i in Found) and (Pos(Keyword,LowerCase(Titles[i])) > 0) then
- begin
- writeln('<IMG SRC="/gif/arrow.gif"> <B>',Titles[i],'</B>');
- write('<BR><IMG SRC="/gif/backblue.gif"HEIGHT="1"WIDTH=24><A HREF="',WebPage[i]);
- if Pos('(index)',Titles[i]) > 0 then write('"TARGET="_top');
- writeln('">',WebPage[i],'</A>');
- if Query < 7 then writeln('<P>')
- else writeln('<BR>');
- Found := Found - [i]
- end
- end;
- writeln('<HR><P>')
-
- end;
- if Found <> [] then
- begin
- for i:=0 to WebPages-1 do
- begin
- if i in Found then
- begin
- writeln('<IMG SRC="/gif/arrow.gif"> ',Titles[i]);
- write('<BR><IMG SRC="/gif/backblue.gif"HEIGHT="1"WIDTH=24><A HREF="',WebPage[i]);
- if Pos('(index)',Titles[i]) > 0 then write('"TARGET="_top');
- writeln('">',WebPage[i],'</A><BR>')
- end
- end
- end;
- writeln('</UL>');
- {$IFDEF DEBUG}
- writeln('<HR>');
- writeln('<B>Not found:</B>');
- writeln('<UL>');
- for i:=0 to WebPages-1 do
- if not (i in Found) then
- writeln('<LI><A HREF="',WebPage[i],'">',WebPage[i],'</A>');
- writeln('</UL>')
- {$ENDIF}
- end.
-